package com.coolgor.coldot.enums.auth;

public enum LocalUserStateEnum {
	UNREGISTER(1,"未注册"),
	UNACTIVE(2, "未激活"), 
	ACTIVE(3, "正常用户"), 
	DENIAL(4, "禁用");

	private int state;

	private String stateInfo;

	private LocalUserStateEnum(int state, String stateInfo) {
		this.state = state;
		this.stateInfo = stateInfo;
	}

	public int getState() {
		return state;
	}

	public String getStateInfo() {
		return stateInfo;
	}

	public static LocalUserStateEnum stateOf(int index) {
		for (LocalUserStateEnum state : values()) {
			if (state.getState() == index) {
				return state;
			}
		}
		return null;
	}

	public static String toJsonString() {
		String res = "";
		for (LocalUserStateEnum state : values()) {
			res += "{'state':'" + state.getState() +"',";
			res += "'stateinfo':'" + state.getStateInfo() +"'},";
		}
		if (res.length()>0) {
			res = "[" + res.substring(0,res.length()-1) + "]";
		}
		return res;
	}
}
